import { Body, Controller, Get, Post } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { Public } from '@/common/auth/global.auth';
import { LoginService } from '@/pmp/services/login/login.service';
import { LoginDto } from '@/pmp/dto/login.dto';
import { PassLoginDto } from '@/pmp/dto/passLogin.dto';

@ApiTags('登录')
@Controller('')
export class LoginController {
  constructor(private readonly loginService: LoginService) {}

  @Public()
  @ApiOperation({ summary: '验证码登录接口' })
  @Post(`/login`)
  login(@Body() body: LoginDto) {
    return this.loginService.login(body);
  }

  @Public()
  @ApiOperation({ summary: '获取验证码' })
  @Get('/authcode')
  async authCode() {
    return await this.loginService.authCode();
  }

  @Public()
  @ApiOperation({ summary: '账号密码登录' })
  @Post('/passLogin')
  passLogin(@Body() body: PassLoginDto) {
    return this.loginService.passLogin(body);
  }
}
